package com.example.design.shejimoshi.action.visitor.practice2;

import com.example.design.shejimoshi.action.visitor.practice2.element.CardStatusResource;
import com.example.design.shejimoshi.action.visitor.practice2.element.TianHeCuCCPlusCardStatusResource;
import com.example.design.shejimoshi.action.visitor.practice2.element.ZhuHaiCardStatusResource;
import com.example.design.shejimoshi.action.visitor.practice2.visit.EditCardStatusVisitor;
import com.example.design.shejimoshi.action.visitor.practice2.visit.QueryCardStatusVisitor;
import com.example.design.shejimoshi.action.visitor.practice2.visit.Visitor;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description
 * @Author liuzhihui
 * @Date 2024/6/26
 */
public class VisitorTest {
    public static void main(String[] args) {
        // 加载所有资源
        List<CardStatusResource> cardStatusResources = loadAllResource();

        // 查询卡状态
        Visitor queryCardStatusVisitor = new QueryCardStatusVisitor();
        for (CardStatusResource cardStatusResource : cardStatusResources) {
            cardStatusResource.accept(queryCardStatusVisitor);
        }

        // 珠海联通修改卡状态
        Visitor editCardStatusVisitor = new EditCardStatusVisitor();
        CardStatusResource zhuHaiCardStatusResource = new ZhuHaiCardStatusResource();
        zhuHaiCardStatusResource.accept(editCardStatusVisitor);
    }

    private static List<CardStatusResource> loadAllResource() {
        List<CardStatusResource> resourceFiles = new ArrayList<>();
        resourceFiles.add(new TianHeCuCCPlusCardStatusResource());
        resourceFiles.add(new ZhuHaiCardStatusResource());
        return resourceFiles;
    }
}
